<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Curl转Pytest与Excel</title>
    <link rel="icon" href="{{ url_for('static', filename='ico/favicon_curl.png') }}">

    <!-- 使用 highlight.js -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/curl_convert.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/curl_to_excel_data.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/alert_msg.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/excel_code.css') }}">

    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/languages/python.min.js"></script>
    <script type="module" src="{{ url_for('static', filename='js/common.js') }}"></script>
    <script type="module" src="{{ url_for('static', filename='js/curl_convert.js') }}"></script>
    <script type="module" src="{{ url_for('static', filename='js/curl_to_pytest_excel.js') }}"></script>
    <script type="module" src="{{ url_for('static', filename='js/curl_to_excel.js') }}"></script>
</head>
<body>

<!-- 隐藏输入框, 用于存储 curl_command -->
<input type="hidden" id="curl_command" name="curl_command" value="{{ curl_command }}">

<!-- Pytest 用例展示区 : -->
<div class="header-container">
    <h2>Pytest 用例:</h2>
    <button class="copy-btn" onclick="copyToClipboard('pytestCode', '用例方法')">复制</button>
</div>
<pre id="pytestCode"><code class="language-python">{{ pytest_test_code }}</code></pre>

<!-- Excel 数据区域 : -->
<div class="header-container">
    <h2>Excel 数据</h2>
    <button class="copy-btn" onclick="clearCache()">清理文件名</button>
    <button class="copy-btn" onclick="write_to_excel_new()">写入用例文件</button>
    <button class="copy-btn" onclick="copyTable()">复制</button>
    <input type="hidden" id="sheet_name_input" name="sheet_name" value="{{ sheet_name }}">
</div>
<table id="dataTable">
    <thead>
    <tr>
        <th>用例编号</th>
        <th>接口名称</th>
        <th>模块</th>
        <th>优先级</th>
        <th>标题</th>
        <th>域名</th>
        <th>URL</th>
        <th>前置条件</th>
        <th>请求方式</th>
        <th>请求头</th>
        <th>请求参数</th>
        <th>预期结果</th>
        <th>响应预期结果</th>
        <th>实际结果</th>
    </tr>
    <tr>
        <th>case_id</th>
        <th>name</th>
        <th>model</th>
        <th>rank</th>
        <th>title</th>
        <th>host</th>
        <th>url</th>
        <th>precondition</th>
        <th>method</th>
        <th>header</th>
        <th>data</th>
        <th>expected</th>
        <th>expected_response</th>
        <th>actual</th>
    </tr>
    </thead>
    <tbody id="tableData">
    <tr>
        <td contenteditable="true">{{ case_id }}</td>
        <td contenteditable="true">{{ api_name }}</td>
        <td contenteditable="true">{{ model }}</td>
        <td contenteditable="true">P1</td>
        <td contenteditable="true">{{ title }}</td>
        <td contenteditable="true">{{ host }}</td>
        <td contenteditable="true">{{ url }}</td>
        <td contenteditable="true"></td>
        <td contenteditable="true">{{ method }}</td>
        <td contenteditable="true"></td>
        <!--        <td contenteditable="true" id="jsonData">-->
        <!--            <pre id="jsonCodeData"><code>{{ data|safe }}</code></pre>-->
        <!--        </td>-->
        <td contenteditable="true" id="jsonData">
            <pre id="jsonCodeCell" style="max-height: 60px; overflow-y: auto;"><code>{{ data|safe }}</code></pre>
        </td>

        <td contenteditable="true">OK</td>
        <td contenteditable="true" id="jsonExpectedData">
            <pre><code id="jsonCodeBlock"></code></pre>
        </td>
        <td contenteditable="true"></td>
    </tr>
    </tbody>
</table>


<!-- Pytest 类展示区 : -->
<div class="header-container">
    <h2>Pytest 用例类:</h2>
    <button class="copy-btn" onclick="copyToClipboard('pytestClass', '用例类')">复制</button>
</div>
<pre id="pytestClass"><code class="language-python">{{ pytest_class_code }}</code></pre>

<!-- 按钮区 : -->
<div class="button-container">
    <a href="/" style="text-decoration: none;">
        <button>返回</button>
    </a>
</div>

<!-- 自定义通知, 右上角的通知区 -->
<div id="custom-alert" class="custom-alert"></div>

</body>
</html>
